//
// Created by 李光辉 on 2021/1/2.
//

#include <stdlib.h>
#include <stdio.h>
#include <omp.h>

void Hello(void); //thread function

int main(int argc, char* argv[])
{
    //get number of threads from command line
    int thread_count = strtol(argv[1], NULL, 10);

#pragma omp parallel num_threads(thread_count)
    Hello();

    return 0;
}

void Hello(void )
{
    int my_rank = omp_get_thread_num();
    int thread_count = omp_get_num_threads();

    printf("Hello from thread %d of %d\n",  my_rank, thread_count);
}

//gcc -g -Wall -fopenmp -o omp_hello 1.omp_hello.c